// 商品详情页

class Goods{
    constructor(){
        this.cont=document.querySelector('.r-items');
    this.getGoods();
    
    }
    // 渲染页面
async getGoods(){
 let data=await axios.get({url:'http://localhost:53000/course1'});
 let html=''
 data.forEach(goods=>{
   
     html+=`
                 <li class="item">
                        <img src="${goods.src}" alt="">
                        <p class="item-name">${goods.name}</p>
                        <p class="item-price">${goods.price}</p>
                        <p class="item-praise">10.4万人好评</p>
                        <div class="item-btn"  onclick="Goods.addCart(${goods.id})">
                          查看详情
                        </div>
                    </li>
     `
     this.cont.innerHTML=html;
 })
}


static addCart(id){
 location.href='./goods.html?=' +id 
}

 
}
new Goods;